wp order archive page post by title

95

// Sort All Tours by Title
add_filter( 'parse_query', 'sorting_archives' );
function sorting_archives( $wp_query ) {
  if (is_post_type_archive( 'tour' ) || is_tax()) {
    $wp_query->set( 'orderby', 'title' );
    $wp_query->set( 'order', 'ASC' );
  }
  return $wp_query;
}

Comments

Submit
0 Comments